#include "Quest.h"
#include "GFuns.h"
#include "Game.h"

class QuestSilverKettle : public Quest
{
public:

	QuestSilverKettle();
	virtual ~QuestSilverKettle(){};

	virtual Phrase* GetPhrase(Character* aCharacter);
	virtual void OnAction(EMenuAction aAction,
		ActionData aArg1 = ActionData(), ActionData aArg2 = ActionData(), ActionData aArg3 = ActionData()){};

private:
	Item silverKettle;
};

QuestSilverKettle::QuestSilverKettle() :
silverKettle(ITEM_QUEST, QUEST_SILVER_KETTLE)
{
}

Phrase* QuestSilverKettle::GetPhrase(Character* aCharacter)
{
	string sentence;
	Character* hero = Game::GetHero();
	phrase = nullptr;

	if(progress == QUEST_STATUS_NEW)
	{
		Phrase* A = Phrase::CreatePhrase("Welcome to our *peaceful*");
		A->AddSubPhrase("little town.");
		A->AddSubPhrase("Show me your teeth.");
		A->AddSubPhrase("Just kidding!");

		Phrase* B = Phrase::CreatePhrase("Of course, of course.");

		Phrase* C = Phrase::CreatePhrase("Of course not.");
		C->AddSubPhrase("Show me your hands!");
		C->AddSubPhrase("They seem normal...");
		C->AddSubPhrase("Well, there is one");
		C->AddSubPhrase("little, little problem.");

		Phrase* D = Phrase::CreatePhrase("Of course, goodbye.");

		Phrase* E = Phrase::CreatePhrase("There is no problem."); 
		E->AddSubPhrase("Everyone is perfectly normal.");
		E->AddSubPhrase("Wait. Oh, right. The problem.");
		E->AddSubPhrase("Yes. Well. They live amongst us");
		E->AddSubPhrase("and look almost like us.");
		E->AddSubPhrase("But they have slightly bigger front teeth");
		E->AddSubPhrase("and black hair on their hands.");

		E->AddSubPhrase("They are very vulnerable to silver.");
		E->AddSubPhrase("That's why I need a silver kettle.");
		E->AddSubPhrase("It's very expensive and I can't afford it.");
		E->AddSubPhrase("Bring me one and you will");
		E->AddSubPhrase("eat here for free.");

		E->AddSubPhrase("I think the guards left a kettle");
		E->AddSubPhrase("somewhere in the dungeon.");
		E->AddSubPhrase("You can enter freely");
		E->AddSubPhrase("but you will need a torch.");
		E->AddSubPhrase("Ask any blacksmith how to");
		E->AddSubPhrase("make a torch on your own.");

		E->AddSubPhrase("Do you accept this little task?");

		Phrase* F = Phrase::CreatePhrase("Go, then!"); 

		phrase = A;

		A->AddOption("I need food.",B);
		A->AddOption("Weird town. Is there something wrong with you?",C);
		A->AddOption("Never mind, goodbye.",D);

		C->AddOption("What's the problem?",E);
		C->AddOption("I don't want to know. I'll live longer.",D);

		E->AddOption("Dungeons, silver appliances, monsters - I'm out.",D);
		E->AddOption("Sounds interesting. I'm in!",F);

		F->SetNextQuestStatus(QUEST_STATUS_TAKEN,this);
	}
	else if(progress == QUEST_STATUS_TAKEN && !hero->HaveItem(&silverKettle))
	{
		phrase = Phrase::CreatePhrase("You don't have the kettle.");
		phrase->AddSubPhrase("Show me your teeth!");
	}
	else if(progress == QUEST_STATUS_TAKEN)
	{
		phrase = Phrase::CreatePhrase("My precious!");
		phrase->AddSubPhrase("Now give it to me!");
		phrase->AddSubPhrase("And wait... I'll cook you something.");
		phrase->AddSubPhrase("Or you can go");
		phrase->AddSubPhrase("and look for new adventures.");
		
		phrase->SetNextQuestStatus(QUEST_STATUS_DONE, this);

		for(int i=0; i<5; i++)
		{
			Item reward(ITEM_FOOD, randInt(FOOD_NONE+1,FOOD_END-1));
			hero->GetInventory()->AddItem(reward);
		}
		hero->GetInventory()->RemoveItem(&silverKettle);
	}

	return phrase;
}

Quest* GetQuestSilverKettle()
{
	return new QuestSilverKettle();
}